package com.nvt.core.services;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nvt.core.dao.IJdbcDAO;
import com.nvt.core.exception.NvtBusinessException;

@Service
public class JdbcServiceImpl implements IJdbcService {

	@Autowired
	private IJdbcDAO jdbcDAO;

	@Override
	public void executeDelete(String entityName, Object[] values)
			throws NvtBusinessException {
		try {
//			Integer integer = new Integer("abc");
			jdbcDAO.executeDelete(entityName, values);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	@Override
	public Integer executeInsert(String entityName, Object[] values)
			throws NvtBusinessException {
		try {
			return jdbcDAO.executeInsert(entityName, values);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	@Override
	public void executeUpdate(String entityName, Object[] values)
			throws NvtBusinessException {
		try {
			jdbcDAO.executeUpdate(entityName, values);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	@Override
	public List<Map<String, Object>> findAll(String entityName)
			throws NvtBusinessException {
		try {
			return jdbcDAO.findAll(entityName);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

	@Override
	public List<Map<String, Object>> findByParameters(String entityName,
			Object[] values) throws NvtBusinessException {
		try {
			return jdbcDAO.findByParameters(entityName, values);
		} catch (Exception e) {
			throw new NvtBusinessException(e.getMessage());
		}
	}

}
